use "[filepath]\2021 AAIM_CDIM Spring Survey_Deidentified.dta"
set more off


////REPRESENTATIVENESS OF RESULTS////

///Individual respondents/nonrespondents
////Survey Respondents and Nonrespondents by Institution/Medical School Type (Public or Private)///
tabulate InstPubPriv respondent, chi expected
tabulate InstPubPriv respondent, column chi exact


//////Responding and Nonresponding Institutions/Medical Schools by Type (Public or Private)///
tabulate InstPubPriv respondinginst, chi expected
tabulate InstPubPriv respondinginst, column chi exact

////Survey Respondents and Nonrespondents by U.S. Census Bureau Region///
quietly tabulate CensusRegion4cats, generate(cens4catsind_) 

tabulate CensusRegion4cats respondent, chi expected
tabulate CensusRegion4cats respondent, column chi exact


///Tests for association///
tabulate cens4catsind_1 respondent, column exact
tabulate cens4catsind_2 respondent, column exact
tabulate cens4catsind_3 respondent, column exact
tabulate cens4catsind_4 respondent, column exact
tabulate cens4catsind_4 respondent if CensusRegion!=5, column exact


/////////Responding and Nonresponding Institutions/Medical Schools by U.S. Census Bureau Region///
tabulate CensusRegion4cats respondinginst, chi expected
tabulate CensusRegion4cats respondinginst, column chi exact


///Tests for association///
tabulate cens4catsind_1 respondinginst, column exact
tabulate cens4catsind_2 respondinginst, column exact
tabulate cens4catsind_3 respondinginst, column exact
tabulate cens4catsind_4 respondinginst, column exact
tabulate cens4catsind_4 respondinginst if CensusRegion!=5, column exact


////Survey Respondents and Nonrespondents by institutional classification//////
quietly tabulate InstClassification, generate(instclassind_) 

tabulate InstClassification respondent, column chi exact
tabulate InstClassification respondent if (instclassind_2!=1 & instclassind_4!=1), column chi exact

tabulate InstClassification respondent if (instclassind_1!=1), column chi exact
tabulate InstClassification respondent if (instclassind_2!=1), column chi exact

tabulate instclassind_1 respondent, column chi exact
tabulate instclassind_2 respondent, column chi exact
tabulate instclassind_3 respondent, column chi exact
tabulate instclassind_4 respondent, column chi exact



////Responding and Nonresponding Institutions/Medical Schools by institutional classification//////

tabulate InstClassification respondinginst, column chi exact

tabulate InstClassification respondinginst if (instclassind_3!=1 & instclassind_2!=1), column chi exact
tabulate InstClassification respondinginst if (instclassind_1!=1 & instclassind_4!=1), column chi exact
tabulate InstClassification respondinginst if (instclassind_1!=1 & instclassind_2!=1), column chi exact

tabulate instclassind_4 respondinginst , column chi exact


//Survey Respondents and Nonrespondents by Self-Reported Gender (From AAIM Membership Database) (From AAIM Member Database)///
tabulate Gender respondent, column chi exact

//Responding and Nonresponding Institutions/Medical Schools by Self-Reported Gender (From AAIM Membership Database)
tabulate Gender respondinginst, column chi exact

//Survey Respondents and Nonrespondents by Number of Clerkship (or Co-/Associate/Assistant) Directors and Sub-Internship Directors per Institution (From AAIM Membership Database)//
tabstat countperinst, by(respondent) statistics( count mean sd median min max IQR) columns(statistics)

median countperinst, by(respondent) exact medianties(split)


//Responding and Nonresponding Institutions/Medical Schools by Number of Clerkship (or Co-/Associate/Assistant) Directors and Sub-Internship Directors per Institution (From AAIM Membership Database)//
tabstat countperinst, by(respondinginst) statistics( count mean sd median min max IQR) columns(statistics)
median countperinst, by(respondinginst) exact medianties(split)

////END REPRESENTATIVENESS OF RESULTS////


///SECTION I/Student Advising for Internal Medicine Residency Applications

////Q5 Do you advise students at your institution about internal medicine residency applications?
tab1 Q5


///Q6 On average, for how many of the following did you advise a typical “middle-third-of-the-class” student at your institution?
//...Number of PROGRAMS to APPLY to?	
//...Number of INTERVIEWS to ACCEPT?
egen tempmode1 = mode(Q6_1_1), maxmode
egen tempmode2 = mode(Q6_2_1), maxmode
egen tempmode3 = mode(Q6_1_2), maxmode
egen tempmode4 = mode(Q6_2_2), maxmode
drop tempmode1 - tempmode4

tabstat Q6_1_1 Q6_2_1 Q6_1_2  Q6_2_2, statistics( count mean sd median min max IQR) columns(statistics)
tabstat Q6_1_1 Q6_2_1 if (Q6_1_1<40 & Q6_2_1<40), statistics( count mean sd median min max IQR) columns(statistics)

ttest Q6_1_1 == Q6_2_1 if (Q6_1_1<40 & Q6_2_1<40)
ttest Q6_1_1 == Q6_2_1 
ttest Q6_1_2 == Q6_2_2 


///Q8 Please answer for the pandemic application cycle (2020-2021), compared to PRIOR cycles (pre-COVID-19).
///How did the following change during the 2020-2021 residency application cycle?
tab1 Q8_1 if Q8_1==4
 tab1 Q8_2 if Q8_2==4
 tab1 Q8_3 if Q8_3==4
 tab1 Q8_4 if Q8_4==4
 tab1 Q8_5 if Q8_5==4
 tab1 Q8_6 if Q8_6==4


///Q9 How prepared were you for your advisor’s role during the 2020-2021 residency application cycle when interviews were conducted virtually?//
tab1 Q9

//Answer to the best of your ability: Compared with pre-COVID-19 application cycles, how likely were your current advisees to…//
tab1 Q10_1 Q10_2 Q10_3

///Q11 Generally speaking, how well could your current advisees assess a residency program(s) during the virtual interview day?
tab1 Q11 

///Q12 If onsite interviews are an option, do you think that the residency recruitment process should remain entirely virtual next year?
tab1 Q12 
gsort - Q12_3_TEXT
gsort - Q12


//Q13 If unrestricted travel is allowed next year, what aspect(s) of virtual interviewing would you like to retain for the 2021-2022 residency interview season? Check all that apply./
mrtab Q13_1 - Q13_6 
gsort - Q13_4_TEXT


//Q14 What challenges did your students experience due to virtual residency interviews? Answer to the best of your ability.
tab1 Q14
///END REPORTING OF SECTION I///



///BEGIN REPORTING SECTION II: Alliance for Academic Internal Medicine (AAIM) Guidance for the 2020 - 2021 Virtual Residency Interviewing Season; and Internal Medicine Clerkship Planning////

///Q16 During the 2020-2021 application cycle (COVID-19), did you use the AAIM Interview Prep Guidance for Medical Student Advisors?//
tab1 Q16

//Q17 Please share any additional comments that you might have about the AAIM Interview Prep Guidance for Medical Student Advisors.
tab1 Q17

///Q19 For the academic year 2021-2022, how many weeks of the internal medicine clerkship do you plan to allocate to inpatient clinical experiences?//
tab1 Q19 
destring (Q19_1_TEXT), replace
gsort - Q19_1_TEXT
tabstat Q19_1_TEXT,  statistics( count mean sd median min max IQR) columns(statistics)

///END REPORTING SECTION II////


//BEGIN REPORTING SECTION III//AAIM Guidelines for Department of Medicine (DOM) Standardized Letters of Evaluation (SLOE)///

//Q21 Did your department of medicine implement the new AAIM Guidelines for DOM Standardized Letters of Evaluation (SLOE) Template during the 2020-2021 (COVID-19) application cycle?//
tab1 Q21 
gsort - Q21_5_TEXT
//

///Q22 Why did your DOM not implement (or if applicable, not fully implement) the DOM Standardized Letters of Evaluation Template this year?
tab1 Q22

///Q23 Which of the following would promote your school’s ability to implement (or to fully implement, if applicable) the new AAIM Guidelines for DOM Standardized Letters of Evaluation (SLOE) Template in the future? Check all that apply.///

mrtab Q23_1 - Q23_13 
tab1 Q23_14 
gsort - Q23_11_TEXT

///END REPORTING SECTION III///


/////BEGIN REPORTING SECTION IV//Clerkship and Sub-Internship Director and Medical School / Institutional Characteristics//

///Q25 What is your primary educational leadership role at your institution?
tab1 Q25 
gsort - Q25_10_TEXT


//Q26 Do you have a secondary educational leadership role at your institution?
tab1 Q26

//Q27 What is your secondary educational leadership role at your institution?
tab1 Q27
gsort - Q27_10_TEXT

//Q28 For how many years have you been in your primary educational role?
tab1 Q28
Q28 Q28_1_TEXT
destring Q28_1_TEXT, replace
gsort - Q28
tabstat Q28_1_TEXT, statistics( count mean sd median min max IQR) columns(statistics)


//Q29 What is your academic rank?
tab1 Q29 
gsort - Q29_5_TEXT


//Q30 For the current academic year (2020-2021), how many students are there in each class at your medical school? 
tabstat Q30, statistics( count mean sd median min max IQR) columns(statistics)

///END REPORTING SECTION IV////


//Q32 The CDIM Council wants to ensure that your needs as a medical education leader are addressed. Please provide one area that you are struggling with and/or would like the CDIM Council to review as an opportunity to better support leaders in your position. If you completed the 2020 CDIM Annual Survey of Core Clerkship Directors and answered this question, you may provide any other comments that you wish to share with the Council.//
gsort - Q32
tab1 Q32


////END STATA DO-FILE/////